<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
    <head>
        <title></title>
        <meta charset="utf-8">
        <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
        <link rel="stylesheet" href="css/fonts/font-awesome.min.css">
        <link rel="stylesheet" href="css/ui-box.css">
        <link rel="stylesheet" href="css/ui-base.css">
        <link rel="stylesheet" href="css/ui-color.css">
        <link rel="stylesheet" href="css/appcan.icon.css">
        <link rel="stylesheet" href="css/appcan.control.css">
    </head>
    <body class="um-vp bc-bg" ontouchstart>
        {"response":{"data":[{"address":"南京市游乐园","province":"江苏","district":"玄武区","city":"南京"}]},"status":"ok"}
        
        <br>
        {"user":{"uid":"33","nick_name":"zqy","uname":"zqy","sex":"\u5973","birthday":"1993-02-22","email":"23572357@qq.com","work_num":"201200403041","section":"\u65e0","position":"\u9171\u6cb9\u90e8","position_sort":"\u65e0","position_level":"\u65e0","head_protrait":"550e6d86f3a74.png","status":"0","reg_time":"1423650751","last_login_time":"1444660954","integral":"339","interview":null,"role_style":"4"},"token":"704c7368f0249e4ede0f1a2f08fb89403aa65177"}
        <div class="btn ub ub-ac bc-text-head ub-pc bc-btn"  id="btn">
            开始解析
        </div>

    </body>
    <script src="js/appcan.js"></script>
    <script src="js/appcan.control.js"></script>
    </body>
    <script>
        appcan.ready(function() {
        });
        appcan.button(".btn", "ani-act", function() {

            // Appcan 解析
            var json = {
                "response" : {
                    "data" : [{
                        "address" : "南京市游乐园",
                        "province" : "江苏",
                        "district" : "玄武区",
                        "city" : "南京"
                    }]
                },
                "status" : "ok",
                "number" : 1,
                name : "何宁",
                pic : null,
                sex : ""
            };
            
            var json2 = {
                    "user" : {
                            "uid" : "33",
                            "nick_name" : "zqy",
                            "uname" : "zqy",
                            "sex" : "\u5973",
                            "birthday" : "1993-02-22",
                            "email" : "23572357@qq.com",
                            "work_num" : "201200403041",
                            "section" : "\u65e0",
                            "position" : "\u9171\u6cb9\u90e8",
                            "position_sort" : "\u65e0",
                            "position_level" : "\u65e0",
                            "head_protrait" : "550e6d86f3a74.png",
                            "status" : "0",
                            "reg_time" : "1423650751",
                            "last_login_time" : "1444660954",
                            "integral" : "339",
                            "interview" : null,
                            "role_style" : "4"
                        },
                        "token":"704c7368f0249e4ede0f1a2f08fb89403aa65177"
                    }
            alert(json2);
            // 转换为String类型
            var mStr = JSON.stringify(json2);

            // 编程JSON对象
            var mJson = JSON.parse(mStr);
            
            var user = mJson.user;
            alert(user);
/*

            // 转换为String类型
            var mStr = JSON.stringify(json);

            // 编程JSON对象
            var mJson = JSON.parse(mStr);

            var mData = mJson.response.data;
            
            alert("mData:" + mData);

            $.each(mData, function(index, result) {
                alert("下标为：" + index);
                alert(result.address);
                alert(result.province);
                alert(result.district);
                alert(result.city);
            });

            alert(mJson.status);
            alert(mJson.number);
            alert(mJson.name);
            alert(mJson.pic);
            var err = mJson.error;
            // 判断是否存在该字段
            if ( typeof (err) == "undefined") {
                alert("没有该字段...这时候得到的值是null");
            }

            // 判断是否有值，就是  sex: ,  这种有键没有值得情况，直接运行不起来
            var sex = mJson.sex;
            if (trim(sex) == "") {
                alert("得到的值为空，也就是没有内容");
            }

            // 删除左右两边的空格
            function trim(str) {
                return str.replace(/(^\s*)|(\s*$)/g, "");
            }

            // Jquery的解析方法
            var json2 = {
                "Products" : [{
                    "id" : "100",
                    "name" : "何宁"
                }, {
                    "id" : "101",
                    "name" : "郭台"
                }],
                "img" : [{
                    "imgId" : "12345",
                    "url" : "my/1.png"
                }]
            };

            $.each(json2.Products, function(i, n) {
                // alert(n.id);
            });
*/
        });
    </script>
</html>
